<!doctype html public "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
<html>
<head>
<title>
 Overview
</title>
<link rel ="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<script>
function asd() {
	
		parent.document.title="dragdrop.js Overview";
	
}
</script>
</head>
<body bgcolor="white" onload="asd();">

<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> 	<font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top">
<em>
<b></b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<center>
	
	   <h2>dragdrop.js</h2>
	
</center>

	


<h4>Summary</h4>
<p>
	
		No overview generated for 'dragdrop.js'<BR/><BR/>
	
</p>

<hr>


    <table border="1" cellpadding="3" cellspacing="0" width="100%">
    <tr bgcolor="#CCCCFF" class="TableHeadingColor">
    <td colspan=2><font size="+2">
    
        <b>Class Summary</b>
    
    </font></td>
    </tr>
    
    <tr bgcolor="white" class="TableRowColor">
    <td width="15%"><b><a href="draw2d/DragDropEvent.html">draw2d.DragDropEvent</a></b></td>
    <td>&nbsp;</td>
    </tr>
    
    <tr bgcolor="white" class="TableRowColor">
    <td width="15%"><b><a href="draw2d/Draggable.html">draw2d.Draggable</a></b></td>
    <td>&nbsp;</td>
    </tr>
    
    <tr bgcolor="white" class="TableRowColor">
    <td width="15%"><b><a href="draw2d/DropTarget.html">draw2d.DropTarget</a></b></td>
    <td>&nbsp;</td>
    </tr>
    
    </table>
    <hr/> 


<!-- ========== METHOD SUMMARY =========== -->

<!-- ========== END METHOD SUMMARY =========== -->


        <pre class="sourceview"><span class="comment">/* This notice must be untouched at all times.

FreeGroup Draw2D 0.9.26
The latest version is available at
http://www.freegroup.de

Copyright (c) 2006 Andreas Herz. All rights reserved.
Created 5. 11. 2006 by Andreas Herz (Web: http://www.freegroup.de )

LICENSE: LGPL

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License (LGPL) as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA,
or see http://www.gnu.org/copyleft/lesser.html
*/</span>

draw2d.Drag=<span class="reserved">function</span>()
{
};

<span class="comment">/**
 * The item currently being dragged.
 * <span class="attrib">@scope</span> private
 */</span>
draw2d.Drag.current <span class="comment">/*: Draggable */</span> = null;
draw2d.Drag.currentTarget <span class="comment">/*:DropTarget */</span>=null;
draw2d.Drag.currentHover = null;
draw2d.Drag.currentCompartment = null;
<span class="comment">/**
 * Indicates whether or not an item is being dragged.
 * <span class="attrib">@scope</span> private
 */</span>
draw2d.Drag.dragging <span class="comment">/*: boolean */</span> = false;

<span class="comment">/**
 * Returns true if an item is being dragged.
 * <span class="attrib">@scope</span> public
 * <span class="attrib">@return</span> True if an item is being dragged, false if not.
 * <span class="attrib">@type</span> boolean
 */</span>
draw2d.Drag.isDragging = <span class="reserved">function</span> () <span class="comment">/*: boolean */</span> 
{
    <span class="reserved">return</span> <span class="reserved">this</span>.dragging;
};

<span class="comment">/**
 * Sets the item being dragged.
 * <span class="attrib">@scope</span> protected
 * <span class="attrib">@param</span> {Draggable} oDraggable The draggable item.
 * <span class="attrib">@type</span> void
 */</span>
draw2d.Drag.setCurrent = <span class="reserved">function</span> (<span class="comment">/*: Draggable */</span>oDraggable ) 
{
    <span class="reserved">this</span>.current = oDraggable;
    <span class="reserved">this</span>.dragging = true;
};

<span class="comment">/**
 * Returns the currently dragged item.
 * <span class="attrib">@scope</span> public
 * <span class="attrib">@return</span> The currently dragged item.
 * <span class="attrib">@type</span> Draggable
 */</span>
draw2d.Drag.getCurrent = <span class="reserved">function</span> ()
{
    <span class="reserved">return</span> <span class="reserved">this</span>.current;
};

<span class="comment">/**
 * Clears the currently dragged item from memory and sets the dragging
 * flag to false.
 * <span class="attrib">@scope</span> protected
 * <span class="attrib">@type</span> void
 */</span>
draw2d.Drag.clearCurrent = <span class="reserved">function</span> () 
{
    <span class="reserved">this</span>.current = null;
    <span class="reserved">this</span>.dragging = false;
    <span class="reserved">this</span>.currentTarget=null;
};

<span class="comment">/**
 * Encapsulates the functionality for a draggable element.&lt;br&gt;
 * This object is usefull if you want create a drag drop object which are
 * not related to the draw2d.Figure class.&lt;br&gt;
 * Use this class if you want create a palette for drag&amp;drop element insert.
 *
 * <span class="attrib">@scope</span> public
 * <span class="attrib">@extends</span> EventTarget
 * <span class="attrib">@class</span>
 */</span>
draw2d.Draggable=<span class="reserved">function</span>(oElement, iConstraints) 
{
    <span class="reserved">this</span>.id   = draw2d.UUID.create();  <span class="comment">/*:String*/</span>

    <span class="comment">/**private*/</span>
    <span class="reserved">this</span>.node=null;

    <span class="comment">/*
     * Inherit properties from EventTarget.
     */</span>
    draw2d.EventTarget.call(<span class="reserved">this</span>);

    <span class="comment">/*
     * Call constructor.
     */</span>
    <span class="reserved">this</span>.construct(oElement, iConstraints);  

    <span class="comment">/**
     * The difference between the x cursor position and left edge of the element.
     * <span class="attrib">@scope</span> private
     * <span class="attrib">@type</span> int
     */</span>  
    <span class="reserved">this</span>.diffX <span class="comment">/*: int */</span> = 0;

    <span class="comment">/**
     * The difference between the y cursor position and top edge of the element.
     * <span class="attrib">@scope</span> private
     * <span class="attrib">@type</span> int
     */</span>  
    <span class="reserved">this</span>.diffY <span class="comment">/*: int */</span> = 0;

    <span class="comment">/**
     * Collection of drop targets for this item.
     * <span class="attrib">@scope</span> private
     * <span class="attrib">@type</span> Array
     */</span>
    <span class="reserved">this</span>.targets = new draw2d.ArrayList();
};

<span class="comment">/*
 * Inherit methods from EventTarget.
 */</span>
draw2d.Draggable.<span class="reserved">prototype</span> = new draw2d.EventTarget();


<span class="comment">/**
 * Creates a new instance based on the given element and the constraints.
 * <span class="attrib">@scope</span> private
 * <span class="attrib">@constructor</span>
 * <span class="attrib">@param</span> {HTMLElement} oElement The DOM element to make draggable.
 * <span class="attrib">@param</span> {int} iConstraints The rules for dragging.
 */</span>
draw2d.Draggable.<span class="reserved">prototype</span>.construct = <span class="reserved">function</span> (<span class="comment">/*:HTMLElement*/</span> oElement)
{
    <span class="reserved">if</span>(oElement===null || oElement===undefined)
       <span class="reserved">return</span>;

    <span class="comment">/**
     * The element to make draggable.
     * <span class="attrib">@private</span>
     * <span class="attrib">@type</span> HTMLElement
     */</span>
    <span class="reserved">this</span>.element <span class="comment">/*: HTMLElement */</span> = oElement;
    <span class="comment">/*
     * Create a pointer to this object.
     */</span>
    var oThis = <span class="reserved">this</span>;

    var dblTemp = <span class="reserved">function</span>()
    {
        <span class="comment">// Check if the user has made a "double click"</span>
        <span class="comment">/*
         * Create a dragstart event and fire it.
         */</span>
        var oDragStartEvent = new draw2d.DragDropEvent();
        oDragStartEvent.initDragDropEvent(<span class="literal">"dblclick"</span>, true);
        oThis.dispatchEvent(oDragStartEvent);
        var oEvent = arguments[0] || window.event;
        oEvent.cancelBubble = true;
        oEvent.returnValue = false;
    }

    <span class="comment">/*
     * Create a temporary function named fnTemp.
     */</span>
    var fnTemp = <span class="reserved">function</span> () 
    {

        <span class="comment">/*
        * Get the event objects, which is either the first
        * argument (for DOM-compliant browsers and Netscape 4.x)
        * or window.event (for IE).
        */</span>
        var oEvent = arguments[0] || window.event;

        var oDragStartEvent = new draw2d.DragDropEvent();
        <span class="comment">// dispatch Event benötigt eventuel die x/y Koordinate um zu bestimmen</span>
        <span class="comment">// ob dieses Even wirklich relevant ist. (z.b. Wo man in dem Object hinein geklickt hat)</span>
        <span class="comment">//</span>
        <span class="reserved">if</span>(oThis.node!==null)
        {
          var xOffset    = oThis.node.getWorkflow().getAbsoluteX();
          var yOffset    = oThis.node.getWorkflow().getAbsoluteY();
          var scrollLeft = oThis.node.getWorkflow().getScrollLeft();
          var scrollTop  = oThis.node.getWorkflow().getScrollTop();
          oDragStartEvent.x = oEvent.clientX - oThis.element.offsetLeft+scrollLeft-xOffset;
          oDragStartEvent.y = oEvent.clientY - oThis.element.offsetTop+scrollTop-yOffset;
        }
        <span class="comment">// Context menu</span>
        <span class="comment">//</span>
        <span class="reserved">if</span>(oEvent.button===2)
        {
           oDragStartEvent.initDragDropEvent(<span class="literal">"contextmenu"</span>, true);
           oThis.dispatchEvent(oDragStartEvent)
        }
        <span class="comment">// Drag&amp;Drop</span>
        <span class="comment">//</span>
        <span class="reserved">else</span>
        {
           oDragStartEvent.initDragDropEvent(<span class="literal">"dragstart"</span>, true);
           <span class="comment">/*
            * If the event isn't cancelled, proceed.
            */</span>
           <span class="reserved">if</span> (oThis.dispatchEvent(oDragStartEvent)) 
           {
              <span class="comment">/*
               * Get the difference between the clientX and clientY
               * and the position of the element.
               */</span>
               oThis.diffX = oEvent.clientX - oThis.element.offsetLeft;
               oThis.diffY = oEvent.clientY - oThis.element.offsetTop;

              <span class="comment">/*
               * Set the currently dragged item.
               */</span>
               draw2d.Drag.setCurrent(oThis);

              <span class="comment">// Error if the user drag the object outside the window and release the mouse button there.</span>
              <span class="comment">// The object glues at the mose pointer.</span>
              <span class="reserved">if</span>(oThis.isAttached==true)
                 oThis.detachEventHandlers();

              <span class="comment">/*
               * Add all DOM event handlers
               */</span>
               oThis.attachEventHandlers();
           }
        }

        oEvent.cancelBubble = true;
        oEvent.returnValue = false;
    };

    <span class="comment">/*
     * Create a temporary function named fnTemp.
     */</span>
    var fnMouseMove = <span class="reserved">function</span> () 
    {
        <span class="comment">// Falls man gerade beim Drag&amp;Drop ist, ist die</span>
        <span class="comment">// MouseOver Anzeige ausgeschaltet</span>
        <span class="comment">//</span>
        <span class="reserved">if</span>(draw2d.Drag.getCurrent()===null)
        {
          <span class="comment">/*
          * Get the event objects, which is either the first
          * argument (for DOM-compliant browsers and Netscape 4.x)
          * or window.event (for IE).
          */</span>
          var oEvent = arguments[0] || window.event;
          <span class="reserved">if</span>(draw2d.Drag.currentHover!==null &amp;&amp; oThis!==draw2d.Drag.currentHover)
          {
             <span class="comment">// this codes will be called if you move the cursor from one figure (the current hover figure)</span>
             <span class="comment">// to another figure without of "touch" the background.</span>
             <span class="comment">//</span>
             var oDropEvent = new draw2d.DragDropEvent();
             oDropEvent.initDragDropEvent(<span class="literal">"mouseleave"</span>, false, oThis);
             draw2d.Drag.currentHover.dispatchEvent(oDropEvent);
          }
          <span class="reserved">if</span>(oThis!==null &amp;&amp; oThis!==draw2d.Drag.currentHover)
          {
              var oDropEvent = new draw2d.DragDropEvent();
              oDropEvent.initDragDropEvent(<span class="literal">"mouseenter"</span>, false, oThis);
              oThis.dispatchEvent(oDropEvent);
          }
          draw2d.Drag.currentHover = oThis;
        }
        <span class="reserved">else</span>
        {
         <span class="comment">// var oEvent = arguments[0] || window.event;</span>
        }
    };

    <span class="comment">/*
     * Determine which method to use to add the event handler.
     */</span>
    <span class="reserved">if</span> (<span class="reserved">this</span>.element.addEventListener) 
    {
        <span class="reserved">this</span>.element.addEventListener(<span class="literal">"mousemove"</span>, fnMouseMove, false);
        <span class="reserved">this</span>.element.addEventListener(<span class="literal">"mousedown"</span>, fnTemp, false);
        <span class="reserved">this</span>.element.addEventListener(<span class="literal">"dblclick"</span>, dblTemp, false);
    } 
    <span class="reserved">else</span> <span class="reserved">if</span> (<span class="reserved">this</span>.element.attachEvent) 
    {
        <span class="reserved">this</span>.element.attachEvent(<span class="literal">"onmousemove"</span>, fnMouseMove);
        <span class="reserved">this</span>.element.attachEvent(<span class="literal">"onmousedown"</span>, fnTemp);
        <span class="reserved">this</span>.element.attachEvent(<span class="literal">"ondblclick"</span>, dblTemp);
    } 
    <span class="reserved">else</span> 
    {
        throw <span class="literal">"Drag not supported in this browser."</span>;
    }
};


<span class="comment">/**
 * Calledback method called by the framework if the object has been dropped.
 * Inherited classes can implement additional functionality in this method.&lt;br&gt;
 * A good example is the creation of a drag&amp;drop palette for object insertion.
 * <span class="attrib">@protected</span>
 * <span class="attrib">@type</span> void
 */</span>
draw2d.Draggable.<span class="reserved">prototype</span>.onDrop = <span class="reserved">function</span>(<span class="comment">/*:int*/</span> eventX, <span class="comment">/*:int*/</span> eventY)
{
};

<span class="comment">/**
 * Attaches event handlers for the mousemove and mouseup events.
 * <span class="attrib">@scope</span> private
 * <span class="attrib">@private</span>
 * <span class="attrib">@type</span> void
 */</span>
draw2d.Draggable.<span class="reserved">prototype</span>.attachEventHandlers = <span class="reserved">function</span> () {

    <span class="comment">/*
     * Create a pointer to this object.
     */</span>
    var oThis = <span class="reserved">this</span>;
    oThis.isAttached = true;

    <span class="comment">/*
     * Create a temporary function named tempMouseMove.
     */</span>
    <span class="reserved">this</span>.tempMouseMove = <span class="reserved">function</span> () 
    {
        <span class="comment">/*
         * Get the event objects, which is either the first
         * argument (for DOM-compliant browsers and Netscape 4.x)
         * or window.event (for IE).
         */</span>
        var oEvent = arguments[0] || window.event;

        <span class="comment">/*
         * Get the new x and y coordinates for the dragged element by
         * subtracting the difference in the x and y direction from 
         * the mouse position on the screen (clientX and clientY).
         */</span>
        var newPos = new draw2d.Point(oEvent.clientX - oThis.diffX, oEvent.clientY - oThis.diffY);

        <span class="comment">// Adjust the new location if the object can snap to a helper</span>
        <span class="comment">// like grid, geometry, ruler,...</span>
        <span class="comment">//</span>
        <span class="reserved">if</span>(oThis.node!==null &amp;&amp; oThis.node.getCanSnapToHelper())
        {
         newPos = oThis.node.getWorkflow().snapToHelper(oThis.node, newPos);
        }

        oThis.element.style.left = newPos.x+<span class="literal">"px"</span>;
        oThis.element.style.top  = newPos.y+<span class="literal">"px"</span>;

        <span class="reserved">if</span>(oThis.node!==null)
        {
	        var scrollLeft = oThis.node.getWorkflow().getScrollLeft();
	        var scrollTop  = oThis.node.getWorkflow().getScrollTop();
	        var xOffset = oThis.node.getWorkflow().getAbsoluteX();
	        var yOffset = oThis.node.getWorkflow().getAbsoluteY();
	        var oDropTarget  = oThis.getDropTarget(oEvent.clientX+scrollLeft-xOffset, oEvent.clientY+scrollTop-yOffset);
	        var oCompartment = oThis.getCompartment(oEvent.clientX+scrollLeft-xOffset, oEvent.clientY+scrollTop-yOffset);
	        <span class="reserved">if</span>(draw2d.Drag.currentTarget!==null &amp;&amp; oDropTarget!=draw2d.Drag.currentTarget)
	        {
	            var oDropEvent = new draw2d.DragDropEvent();
	            oDropEvent.initDragDropEvent(<span class="literal">"dragleave"</span>, false, oThis);
	            draw2d.Drag.currentTarget.dispatchEvent(oDropEvent);
	        }
	        <span class="reserved">if</span>(oDropTarget!==null &amp;&amp; oDropTarget!==draw2d.Drag.currentTarget)
	        {
	            var oDropEvent = new draw2d.DragDropEvent();
	            oDropEvent.initDragDropEvent(<span class="literal">"dragenter"</span>, false, oThis);
	            oDropTarget.dispatchEvent(oDropEvent);
	        }
	        draw2d.Drag.currentTarget = oDropTarget;
	
	
	        <span class="reserved">if</span>(draw2d.Drag.currentCompartment!==null &amp;&amp; oCompartment!==draw2d.Drag.currentCompartment)
	        {
	            var oDropEvent = new draw2d.DragDropEvent();
	            oDropEvent.initDragDropEvent(<span class="literal">"figureleave"</span>, false, oThis);
	            draw2d.Drag.currentCompartment.dispatchEvent(oDropEvent);
	        }
	        <span class="reserved">if</span>(oCompartment!==null &amp;&amp; oCompartment.node!=oThis.node &amp;&amp; oCompartment!==draw2d.Drag.currentCompartment)
	        {
	            var oDropEvent = new draw2d.DragDropEvent();
	            oDropEvent.initDragDropEvent(<span class="literal">"figureenter"</span>, false, oThis);
	            oCompartment.dispatchEvent(oDropEvent);
	        }
	        draw2d.Drag.currentCompartment = oCompartment;
        }
        <span class="comment">/*
         * Create and fire a drag event.
         */</span>
        var oDragEvent = new draw2d.DragDropEvent();
        oDragEvent.initDragDropEvent(<span class="literal">"drag"</span>, false);
        oThis.dispatchEvent(oDragEvent);
    };

    <span class="comment">/*
     * Create a temporary function for the mouseup event.
     */</span>
    oThis.tempMouseUp = <span class="reserved">function</span> () {

        <span class="comment">/*
         * Detach all of the event handlers.
         */</span>
        oThis.detachEventHandlers();

        <span class="comment">/*
         * Get the event object.
         */</span>
        var oEvent = arguments[0] || window.event;

        <span class="reserved">if</span>(oThis.node!==null)
        {
	        <span class="comment">/*
	         * Determine if the mouse is over a drop target.
	         */</span>
	        var scrollLeft = oThis.node.getWorkflow().getScrollLeft();
	        var scrollTop  = oThis.node.getWorkflow().getScrollTop();
	        var xOffset = oThis.node.getWorkflow().getAbsoluteX();
	        var yOffset = oThis.node.getWorkflow().getAbsoluteY();
	        var oDropTarget = oThis.getDropTarget(oEvent.clientX+scrollLeft-xOffset, oEvent.clientY+scrollTop-yOffset);
		    var oCompartment= oThis.getCompartment(oEvent.clientX+scrollLeft-xOffset, oEvent.clientY+scrollTop-yOffset);
	        <span class="reserved">if</span> (oDropTarget !== null) 
	        {
	            var oDropEvent = new draw2d.DragDropEvent();
	            oDropEvent.initDragDropEvent(<span class="literal">"drop"</span>, false, oThis);
	            oDropTarget.dispatchEvent(oDropEvent);
	        }
	        <span class="reserved">if</span> (oCompartment !== null &amp;&amp; oCompartment.node !== oThis.node) 
	        {
	            var oDropEvent = new draw2d.DragDropEvent();
	            oDropEvent.initDragDropEvent(<span class="literal">"figuredrop"</span>, false, oThis);
	            oCompartment.dispatchEvent(oDropEvent);
	        }
	
	        <span class="reserved">if</span>(draw2d.Drag.currentTarget!==null)
	        {
	            var oDropEvent = new draw2d.DragDropEvent();
	            oDropEvent.initDragDropEvent(<span class="literal">"dragleave"</span>, false, oThis);
	            draw2d.Drag.currentTarget.dispatchEvent(oDropEvent);
	            draw2d.Drag.currentTarget=null;
	        }
        }
        <span class="comment">/*
         * Create and fire a dragend event.
         */</span>
        var oDragEndEvent = new draw2d.DragDropEvent();
        oDragEndEvent.initDragDropEvent(<span class="literal">"dragend"</span>, false);
        oThis.dispatchEvent(oDragEndEvent);

      	oThis.onDrop(oEvent.clientX, oEvent.clientY);

        draw2d.Drag.currentCompartment=null;
        draw2d.Drag.clearCurrent();
    };

    <span class="comment">/*
     * Determine which method to use to add the event handlers for
     * the mousemove and mouseup events.
     */</span>
    <span class="reserved">if</span> (document.body.addEventListener) {
        document.body.addEventListener(<span class="literal">"mousemove"</span>, <span class="reserved">this</span>.tempMouseMove, false);
        document.body.addEventListener(<span class="literal">"mouseup"</span>, <span class="reserved">this</span>.tempMouseUp, false);
    } <span class="reserved">else</span> <span class="reserved">if</span> (document.body.attachEvent) {
        document.body.attachEvent(<span class="literal">"onmousemove"</span>, <span class="reserved">this</span>.tempMouseMove);
        document.body.attachEvent(<span class="literal">"onmouseup"</span>, <span class="reserved">this</span>.tempMouseUp);
    } <span class="reserved">else</span> {
        throw new Error(<span class="literal">"Drag doesn't support this browser."</span>);
    }
};

<span class="comment">/**
 * Detaches event handlers for the mousemove and mouseup events.
 * <span class="attrib">@scope</span> private
 */</span>
draw2d.Draggable.<span class="reserved">prototype</span>.detachEventHandlers = <span class="reserved">function</span> () 
{
    <span class="reserved">this</span>.isAttached = false;
    <span class="comment">/*
     * Determine the method for removing the event handlers for the
     * mousemove and mouseup events.
     */</span>
    <span class="reserved">if</span> (document.body.removeEventListener) {
        document.body.removeEventListener(<span class="literal">"mousemove"</span>, <span class="reserved">this</span>.tempMouseMove, false);
        document.body.removeEventListener(<span class="literal">"mouseup"</span>, <span class="reserved">this</span>.tempMouseUp, false);
    } <span class="reserved">else</span> <span class="reserved">if</span> (document.body.detachEvent) {
        document.body.detachEvent(<span class="literal">"onmousemove"</span>, <span class="reserved">this</span>.tempMouseMove);
        document.body.detachEvent(<span class="literal">"onmouseup"</span>, <span class="reserved">this</span>.tempMouseUp);
    } <span class="reserved">else</span> {
        throw new Error(<span class="literal">"Drag doesn't support this browser."</span>);
    }
};

<span class="comment">/**
 * Determines the drop target that the mouse is over.
 * <span class="attrib">@scope</span> private
 * <span class="attrib">@param</span> x The x-coordinate of the mouse.
 * <span class="attrib">@param</span> y The y-coordinate of the mouse.
 * <span class="attrib">@return</span> The drop target if the mouse is over one, null otherwise.
 */</span>
draw2d.Draggable.<span class="reserved">prototype</span>.getDropTarget = <span class="reserved">function</span> (<span class="comment">/*:int*/</span> x ,<span class="comment">/*:int*/</span>  y )
{
  <span class="reserved">for</span>(var i=0;i&lt;<span class="reserved">this</span>.targets.getSize();i++)
  {
    var target = <span class="reserved">this</span>.targets.get(i);
    <span class="reserved">if</span> (target.node.isOver(x, y) &amp;&amp; target.node!==<span class="reserved">this</span>.node)
    {
        <span class="reserved">return</span> target;
    }
  }
  <span class="reserved">return</span> null;
};

<span class="comment">/**
 * Determines the compartment target that the mouse is over.
 * <span class="attrib">@private</span>
 * <span class="attrib">@param</span> {int} x The x-coordinate of the mouse.
 * <span class="attrib">@param</span> {int} y The y-coordinate of the mouse.
 * <span class="attrib">@return</span> The drop target if the mouse is over one, null otherwise.
 */</span>
draw2d.Draggable.<span class="reserved">prototype</span>.getCompartment = <span class="reserved">function</span> (x <span class="comment">/*: int */</span>, y <span class="comment">/*: int */</span>) <span class="comment">/*: DropTarget */</span> 
{
  var result = null;
  <span class="reserved">for</span>(var i=0;i&lt;<span class="reserved">this</span>.node.getWorkflow().compartments.getSize();i++)
  {
    var target = <span class="reserved">this</span>.node.getWorkflow().compartments.get(i);
    <span class="reserved">if</span> (target.isOver(x, y) &amp;&amp; target!==<span class="reserved">this</span>.node)
    {
        <span class="reserved">if</span>(result===null)
           result = target;
        <span class="reserved">else</span> <span class="reserved">if</span>(result.getZOrder() &lt; target.getZOrder())
           result = target;
    }
  }
  <span class="reserved">return</span> result===null?null:result.dropable;
};


<span class="comment">/**
 * Returns the left coordinate of the element.
 * <span class="attrib">@scope</span> public
 * <span class="attrib">@return</span> The left coordinate of the element.
 */</span>
draw2d.Draggable.<span class="reserved">prototype</span>.getLeft = <span class="reserved">function</span> () <span class="comment">/*: int */</span> 
{
    <span class="reserved">return</span> <span class="reserved">this</span>.element.offsetLeft;
};

<span class="comment">/**
 * Returns the top coordinate of the element.
 * <span class="attrib">@scope</span> public
 * <span class="attrib">@return</span> The top coordinate of the element.
 */</span>
draw2d.Draggable.<span class="reserved">prototype</span>.getTop = <span class="reserved">function</span> () <span class="comment">/*: int */</span> 
{
    <span class="reserved">return</span> <span class="reserved">this</span>.element.offsetTop;
};

<span class="comment">/**
 * Encapsulates information about a drag drop event.
 * <span class="attrib">@class</span>
 * <span class="attrib">@scope</span> public
 * <span class="attrib">@extends</span> Event
 */</span>
draw2d.DragDropEvent=<span class="reserved">function</span>()
{
    <span class="comment">/*
     * Inherit properties from Event.
     */</span>
    draw2d.AbstractEvent.call(<span class="reserved">this</span>);
};

<span class="comment">/*
 * Inherit methods from Event.
 */</span>
draw2d.DragDropEvent.<span class="reserved">prototype</span> = new draw2d.AbstractEvent();

<span class="comment">/**
 * Initializes the event object with information for the event.
 * <span class="attrib">@scope</span> public
 * <span class="attrib">@param</span> sType The type of event encapsulated by the object.
 * <span class="attrib">@param</span> bCancelable True if the event can be cancelled.
 * <span class="attrib">@param</span> oRelatedTarget The alternate target related to the event.
 */</span>
draw2d.DragDropEvent.<span class="reserved">prototype</span>.initDragDropEvent = <span class="reserved">function</span>(sType <span class="comment">/*: String */</span>,
                                                      bCancelable <span class="comment">/*: boolean */</span>,
                                                      oRelatedTarget <span class="comment">/*: EventTarget */</span>) {
    <span class="comment">/*
     * Call inherited method initEvent().
     */</span>
    <span class="reserved">this</span>.initEvent(sType, bCancelable);

    <span class="comment">/*
     * Assign related target (may be null).
     */</span>
    <span class="reserved">this</span>.relatedTarget = oRelatedTarget;
};

<span class="comment">/**
 * A target for a Draggable to be dropped.
 * <span class="attrib">@scope</span> public
 * <span class="attrib">@class</span>
 * <span class="attrib">@extends</span> EventTarget
 */</span>
draw2d.DropTarget=<span class="reserved">function</span>(oElement)
{
    <span class="comment">/*
     * Inherit properties from EventTarget.
     */</span>
    draw2d.EventTarget.call(<span class="reserved">this</span>);

    <span class="comment">/*
     * Call constructor.
     */</span>
    <span class="reserved">this</span>.construct(oElement);
};

<span class="comment">/*
 * Inherit methods from EventTarget.
 */</span>
draw2d.DropTarget.<span class="reserved">prototype</span> = new draw2d.EventTarget();

<span class="comment">/**
 * Creates a new instance based on the given DOM element.
 * <span class="attrib">@constructor</span>
 * <span class="attrib">@scope</span> public
 * <span class="attrib">@param</span> oElement The DOM element to make into a drop target.
 */</span>
draw2d.DropTarget.<span class="reserved">prototype</span>.construct = <span class="reserved">function</span> (oElement <span class="comment">/*: HTMLElement */</span>) 
{
    <span class="comment">/**
     * The DOM element to use as a drop target.
     * <span class="attrib">@scope</span> private
     */</span>
    <span class="reserved">this</span>.element = oElement;
};

<span class="comment">/**
 * Returns the left coordinate of the drop target.
 * <span class="attrib">@scope</span> public
 * <span class="attrib">@return</span> The left coordinate of the drop target.
 */</span>
draw2d.DropTarget.<span class="reserved">prototype</span>.getLeft = <span class="reserved">function</span> () <span class="comment">/*: int */</span> 
{
    var el = <span class="reserved">this</span>.element;
    var ol=el.offsetLeft;
    <span class="reserved">while</span>((el=el.offsetParent) !== null)
    {
        ol += el.offsetLeft;
    }
    <span class="reserved">return</span> ol;
};

<span class="comment">/**
 * Returns the top coordinate of the drop target.
 * <span class="attrib">@scope</span> public
 * <span class="attrib">@return</span> The top coordinate of the drop target.
 */</span>
draw2d.DropTarget.<span class="reserved">prototype</span>.getTop = <span class="reserved">function</span> () <span class="comment">/*: int */</span>
{
  var el = <span class="reserved">this</span>.element;
  var ot=el.offsetTop;
  <span class="reserved">while</span>((el=el.offsetParent) !== null)
  {
     ot += el.offsetTop;
  }
  <span class="reserved">return</span> ot;
};

<span class="comment">/**
 * Returns the height of the drop target.
 * <span class="attrib">@scope</span> public
 * <span class="attrib">@return</span> The height of the drop target.
 */</span>
draw2d.DropTarget.<span class="reserved">prototype</span>.getHeight = <span class="reserved">function</span> () <span class="comment">/*: int */</span>
{
    <span class="reserved">return</span> <span class="reserved">this</span>.element.offsetHeight;
};

<span class="comment">/**
 * Returns the width of the drop target.
 * <span class="attrib">@scope</span> public
 * <span class="attrib">@return</span> The width of the drop target.
 */</span>
draw2d.DropTarget.<span class="reserved">prototype</span>.getWidth = <span class="reserved">function</span> () <span class="comment">/*: int */</span>
{
    <span class="reserved">return</span> <span class="reserved">this</span>.element.offsetWidth;
}</pre>
	<hr>



<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top"><em>
<b></b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<font size="-1">

</font>
<div class="jsdoc_ctime">Documentation generated by <a href="http://jsdoc.sourceforge.net/" target="_parent">JSDoc</a> on Mon Nov 14 13:45:39 2011</div>
</body>
</html>
